<?php

namespace addons\shopro\controller\wm;

use addons\shopro\exception\Exception;
use think\Db;
use addons\shopro\controller\Base as AddonsBase;
class Advert extends AddonsBase
{

    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * banner
     * 王猛 2022-1-24 20:44:59
     */
    public function list()
    {
        $platform = $this->request->param('platform');
        $city = $this->request->param('city');
        $types = $platform=='wxMiniProgram'?'0':'1'; 
        $res = Db::name('wm_advert')
            ->where('types', $types)
            ->where('status', 'normal')
            ->where('city', 'like','%'.$city.'%')
            ->field("id,url,image,shopro_goods_id")
            ->select();
        if(empty($res)){
            $res = Db::name('wm_advert')
                ->where('status', 'normal')
                ->where('iscom_switch', '1')
                ->field("id,url,image")
                ->select();
        }
        $this->success('',$res??[]);
    }




}